﻿Imports System.Runtime.InteropServices

Public Class RunAAUSP

    Declare Auto Function SendMessage Lib "user32.dll" (ByVal hWnd As HandleRef, ByVal msg As Int32, ByVal wParam As IntPtr, ByVal lParam As IntPtr) As Int32

    Private Sub RunAAUSP_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Const BCM_SETSHIELD As Int32 = &H160C
        YesBtn.FlatStyle = Windows.Forms.FlatStyle.System
        SendMessage(New HandleRef(YesBtn, YesBtn.Handle), BCM_SETSHIELD, IntPtr.Zero, CType(1, IntPtr))
    End Sub

    Private Sub YesBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles YesBtn.Click
        Try
            Dim Proc As New Process
            Dim ProcStartInfo As New ProcessStartInfo("C:\Program Files\Startup Manager\AAUSP.exe", My.Application.Info.Version.ToString)
            ProcStartInfo.UseShellExecute = True
            ProcStartInfo.Verb = "runas"
            Proc.StartInfo = ProcStartInfo
            My.Computer.Registry.CurrentUser.OpenSubKey("Software", True).CreateSubKey("Startup Manager")
            My.Computer.Registry.CurrentUser.OpenSubKey("Software\Startup Manager\", True).SetValue("Startup Manager Location", Reflection.Assembly.GetExecutingAssembly().Location())
            Proc.Start()
            Me.Close()
        Catch ex As Exception

        End Try
    End Sub

    Private Sub NoBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NoBtn.Click
        Me.Close()
    End Sub
End Class